package com.zztl.infiniteBand.ui.view

import android.content.Context
import android.view.View
import android.view.animation.AlphaAnimation
import android.view.animation.Animation
import android.view.animation.AnimationSet


/**
 * Created by caspar on 2017/7/27.
 */

object WebviewUtils {

    fun hideProgress(context: Context, progressBarView: WebProgressBarView) {
        val animation = getDismissAnim(context)
        animation.setAnimationListener(object : Animation.AnimationListener {
            override fun onAnimationStart(animation: Animation) {}

            override fun onAnimationEnd(animation: Animation) {

                progressBarView.visibility = View.GONE
            }

            override fun onAnimationRepeat(animation: Animation) {}
        })
        progressBarView.startAnimation(animation)
    }

    fun getDismissAnim(context: Context): AnimationSet {
        val dismiss = AnimationSet(context, null)
        val alpha = AlphaAnimation(1.0f, 0.0f)
        alpha.duration = 1000
        dismiss.addAnimation(alpha)
        return dismiss
    }
}
